<?
 $hotel_id=(isset($selected_hotel_id)?$selected_hotel_id:0);
 $message = ($this->session->flashdata('message')!='')?$this->session->flashdata('message'):'0';
 $err 	 = ($this->session->flashdata('err')!='')?$this->session->flashdata('err'):'0'; 
 
 $selected_tab = ($this->session->flashdata('selected_tab')==''?'hotel_gallery':$this->session->flashdata('selected_tab'));
?> 
<script type="text/javascript">
jQuery(function($) {
	$("#btn_go_back").click(function(){
	   window.location.replace("/admin/hotel");
	});
});

jQuery(function($) {
	$("#btn_delete_hotel").click(function(){
		var res=confirm("Are you sure you want to delete this hotel?"); 
		if(res==true){
			window.location.replace("/admin/hotel/delete/<?=$hotel_id?>");
		} 
	});
});

jQuery(function($) { 
	  if(jQuery("#nortify").css('display')!= 'none'){
        jQuery("#nortify").fadeOut(4000);
	 }
});
  
 
function delete_gi_confirmation(path){
	var res=confirm("Are you sure you want to delete this image?");
	if(res==true){
		window.location.replace(path);
	}
} 


jQuery(document).ready(function() {
	
	//jQuery('.hotel_tabcontent > div').hide();
	//jQuery('.hotel_tabcontent > div:first-child').show();
	//jQuery('.tabs > li:first-child').addClass('selected');
	
	jQuery('.hotel_tabcontent > div').hide();
	jQuery('#<?=$selected_tab?>').show();
	jQuery('#li_<?=$selected_tab?>').addClass('selected');
	jQuery('.tabs > li a').click(function() {
		var tab_id = $(this).attr('href');
		jQuery(tab_id).parent().children().hide();
		jQuery(tab_id).fadeIn();
		jQuery(this).parent().parent().children().removeClass('selected');
		jQuery(this).parent().addClass('selected');
		return false;
	});
	
});

	

</script>
<section id="content">
	<section class="container_12 clearfix">
		<section id="main" class="grid_12">
			<article class="content">
				<h1>Add hotel information</h1>  
                <?= validation_errors('<div id="info_msg" style="display:block;"  class="error msg">','</div>') ?>
				<?
					if(isset($message_id)){
						switch($message_id){
							case 'i':{
								echo '<div id="nortify" style="display:block;" class="success msg">The hotel has been added successfully.</div>';
							}break;
							case 'u':{
								echo '<div id="nortify" style="display:block;" class="success msg">The hotel has been updated successfully.</div>';
							}break;
						}
					} 
                 
				 	$attributes = array('name' => 'hotel_save', 'id' => 'hotel_save');
					echo form_open('admin/hotel/save', $attributes); 
				?>
				<?=form_hidden('hotel_id',$hotel_id);?>
					<ul class="tabs">
						<li id='li_general'><a href="#general">Hotel Edit</a></li>
						<li id='li_settings'><a href="#settings">Settings</a></li>
						<li id='li_facilities'><a href="#facilities">Facilities</a></li>
                        <li id='li_hotel_gallery'><a href="#hotel_gallery">Hotel Gallery</a></li>
					</ul>
					<div class="hotel_tabcontent">
						<div id="general">
							<dl class="inline">
<?
$data = array(
	'name'=>'name',
	'id'=>'name',
	'value'=>(isset($hotel_data)?$hotel_data[0]->name:''),
	'maxlength'=>'100',
	'size'=>'50',
	'class'=>'medium'
);
?>
								<dt><label for="site_title">Hotel Name</label></dt>
								<dd>
									<?=form_input($data)?>
									<!--<small>The title of your website</small>-->
								</dd>
<?
$options = NULL;
foreach($city_list as $city){
	$options[$city->id]=$city->name;	
}
?>
								<dt><label for="tagline">City</label></dt>
								<dd>
                                 	<?=form_dropdown('city_id', $options,(isset($hotel_data)?$hotel_data[0]->city_id:''))?>
									<!--<input type="text" id="tagline" class="medium" />-->
									<!--<small>In a few words, explain what this site is about.</small>-->
								</dd>
<?
$options=NULL;
foreach($hotel_category_list as $category){
	$options[$category->id]=$category->name;	
}
?>
								<dt><label for="site_url">Category</label></dt>
								<dd>
									<!--<input type="text" id="site_url" class="medium" />-->
								<!--	<small>Your website address</small>-->
                                <?=form_dropdown('category_id', $options,(isset($hotel_data)?$hotel_data[0]->category_id:''));?>
								</dd>
<?
$options = NULL;
$options = array(
  '3'=>'3-Star',
  '5'=>'5-Star',
  '7'=>'7-Star' 
);
?>
								<dt><label for="footer_text">Star Rate</label></dt>
								<dd>
									<?=form_dropdown('star_rate', $options,(isset($hotel_data)?$hotel_data[0]->star_rate:''));?>
								</dd>
<?
$options = NULL;
$options = array(
  '1'=>'Type-1',
  '2'=>'Type-2',
  '3'=>'Type-3' 
);
?>
								<dt><label for="footer_text">Hotel Type</label></dt>
								<dd>
									<?=form_dropdown('hotel_type_id', $options,(isset($hotel_data)?$hotel_data[0]->hotel_type_id:''));?>
								</dd>
<?
$data = array(
  'name'        => 'description_location',
  'id'          => 'description_location',
  'value'       => (isset($hotel_data)?$hotel_data[0]->description_location:''), 
  'size'        => '40',
  'style'       => 'width:100%',
);		
?>
                                <dt><label for="site_description">Description Location</label></dt>
								<dd>
									<?=form_textarea($data)?>
								<!--	<small>The meta description of your website</small>-->
								</dd>
<?
$data = array(
	'name'        => 'description_location_enabled',
	'id'          => 'description_location_enabled',
	'value'       => '1',
	'checked'     => (isset($hotel_data)?$hotel_data[0]->description_location_enabled:false),
	'style'       => 'margin:10px',
);
?>
                                <dt><label for="site_description">Description Location Enabled</label></dt>
								<dd><?=form_checkbox($data);?></dd>
								<!--	<small>The meta description of your website</small>--> 
<?
$data = array(
  'name'        => 'description_accommodation',
  'id'          => 'wysiwyg',
  'value'       => (isset($hotel_data)?$hotel_data[0]->description_accommodation:''), 
  'size'        => '40',
  'style'       => 'width:100%',
);			
?>
                                <dt><label for="site_description">Description Accommodation</label></dt>
								<dd>
									<?=form_textarea($data)?>
								<!--	<small>The meta description of your website</small>-->
								</dd>
<?
$data = array(
	'name'        => 'description_accommodation_enabled',
	'id'          => 'description_accommodation_enabled',
	'value'       => '1',
	'checked'     => (isset($hotel_data)?$hotel_data[0]->description_accommodation_enabled:false),
	'style'       => 'margin:10px',
);
?>
                                <dt><label for="site_description">Description Accommodation Enabled</label></dt>
								<dd><?=form_checkbox($data);?></dd>
<?
$data = array(
  'name'        => 'description_facilities',
  'id'          => 'wysiwyg',
  'value'       => (isset($hotel_data)?$hotel_data[0]->description_facilities:''), 
  'size'        => '40',
  'style'       => 'width:100%',
);			
?>
                                <dt><label for="site_description">Description Facilities</label></dt>
								<dd>
									<?=form_textarea($data)?>
								<!--	<small>The meta description of your website</small>-->
								</dd>
<?
$data = array(
	'name'        => 'description_facilities_enabled',
	'id'          => 'description_facilities_enabled',
	'value'       => '1',
	'checked'     => (isset($hotel_data)?$hotel_data[0]->description_facilities_enabled:false),
	'style'       => 'margin:10px',
);
?>
                                <dt><label for="site_description">Description Facilities Enabled</label></dt>
								<dd><?=form_checkbox($data);?></dd>                                
<?
$data = array(
  'name'        => 'description_excursions',
  'id'          => 'description_excursions',
  'value'       => (isset($hotel_data)?$hotel_data[0]->description_excursions:''), 
  'size'        => '40',
  'style'       => 'width:100%',
);		
?>
                                <dt><label for="site_description">Description Excursions</label></dt>
								<dd>
									<?=form_textarea($data)?>
								<!--	<small>The meta description of your website</small>-->
								</dd>
<?
$data = array(
	'name'        => 'description_excursions_enabled',
	'id'          => 'description_excursions_enabled',
	'value'       => '1',
	'checked'     => (isset($hotel_data)?$hotel_data[0]->description_excursions_enabled:false),
	'style'       => 'margin:10px',
);
?>
                                <dt><label for="site_description">Description Excursions Enabled</label></dt>
								<dd style="vertical-align:top;"><?=form_checkbox($data);?></dd>                                
                                
                                                                
								<!--<dt><label for="site_logo">Logo</label></dt>
								<dd>
									<input type="file" id="site_logo" />
									<small>Your website logo (jpg, gif, png)</small>
								</dd>-->
							</dl>
						</div>
						<div id="settings">
							<dl class="inline">
								<?
$data = array(
  'name'        => 'domain_live',
  'id'          => 'domain_live',
  'value'       => (isset($hotel_data)?$hotel_data[0]->domain_live:''),
  'maxlength'   => '150',
  'size'        => '50',
  'style'       => 'width:50%',
);
?>
                                <dt><label for="site_description">Live Domain</label></dt>
								<dd><?=form_input($data)?></dd> 
                                
<?
$data = array(
	'name'=> 'domain_sub',
	'id' => 'domain_sub',
	'value'=> (isset($hotel_data)?$hotel_data[0]->domain_sub:''),
	'maxlength'=>'150',
	'size'=>'50',
	'style'=>'width:50%',
	'class'=>'smal'
);
?>
                                <dt><label for="site_description">Sub Domain</label></dt>
								<dd><?=form_input($data)?></dd>
                                
<?
$data = array(
	'name'=> 'distance_to_nearest_city',
	'id' => 'distance_to_nearest_city',
	'value'=> (isset($hotel_data)?($hotel_data[0]->distance_to_nearest_city!=''?$hotel_data[0]->distance_to_nearest_city:'0'):'0'),
	'maxlength'=>'10',
	'size'=>'10', 
    'class'=>'smal'
);
?>
                                <dt>
                                  <label for="site_description">Distance to the nearest city</label></dt>
								<dd><?=form_input($data)?>&nbsp;km</dd>  
<?
$options = NULL;
$options = array(
  '1'=>'New',
  '2'=>'Pending Verification',
  '3'=>'Verified',
  '4'=>'Disabled',
);
?>
								<dt><label for="footer_text">Status</label></dt>
								<dd>
									<?=form_dropdown('status_id', $options,(isset($hotel_data)?$hotel_data[0]->status_id:''));?>
								</dd>
							</dl>
						</div>
						<div id="facilities">
							<dl class="inline">  
                               <dt>
                                 <label for="admin_email">Hotel Facilities </label></dt>
                                 <dd><?
								 	if(isset($hotel_facilities) && $hotel_facilities!=NULL){
										$icons_per_page = 6;
										$no_of_facilities=count($hotel_facilities);
										$rows=($no_of_facilities%$icons_per_page);
										if($rows==0){
											$rows = ($no_of_facilities/$icons_per_page);	
										}else{
											$rows =	($no_of_facilities/$icons_per_page)+1;
										}
										//print_r($hotel_facilities);
										?>
                                    <div style="width:<?=($rows*125)?>px;float:left;">
									 <?
										foreach($hotel_facilities as $facility){?>
											<label style="float:left;"><img style="border:0px;padding:0px;" src="/images/hotel-facility/<?=$facility['icon']?>" title="<?=$facility['name']?>" />
                                   			<input type="checkbox" id="selected_hotel_facilities" <?=($facility['checked']==true?"checked=\"checked\"":"")?> name="selected_hotel_facilities[]" value="<?=$facility['id']?>" />
                                            </label>
									 <? }?>
									 </div>
									 <?
									} 
								 ?> 
                               </dd>  
						    </dl>
						 </div>

                        <div id="hotel_gallery">
                             <article>
                               <!-- <h1><? //=$page_title?></h1>-->
                                <ul class="photos sortable ui-sortable"><?	
                                    
                                    if($message!='0'){?>
                                         <div id="info_message"><b><?=$message?></b></div><?	
                                    }
                                    if($err!='0'){?>
                                         <div id="info_error"><b><?=$err?></b></div><?	
                                    }
                                                        
                                    if($hotel_gallery_list==NULL){?>
                                        <div class="glr_img_not_found_msg"> No Gallery Images Found! </div><?	
                                    }else{
                                        foreach($hotel_gallery_list as $hotel_image){
                                            $image_path		='';
                                            $thumb_img_path	='';
                                            $delete_path 		= "/admin/hotel/gallery/".$hotel_image->hotel_id."/4/".$hotel_image->id;
                                            if($hotel_image->image!=''){
                                                $image_path  		= "/uploads/hotel/".$hotel_image->hotel_id."/gallery/".$hotel_image->image;
                                                $thumb_img_path_arr = explode('.',$hotel_image->image);
                                                $thumb_img 			= $thumb_img_path_arr[0]."_thumb.".$thumb_img_path_arr[1];
                                                $thumb_img_path 	= "/uploads/hotel/".$hotel_image->hotel_id."/gallery/".$thumb_img;
                                                
                                                if(file_exists(substr($image_path,1)) && is_file(substr($image_path,1))){
                                                    $image_path		= $image_path;									
                                                }else{
                                                    $image_path		='/images/not_found.gif';
                                                    $thumb_img_path ='/images/not_found.gif'; 
                                                }
                                                
                                                if(file_exists(substr($thumb_img_path,1)) && is_file(substr($thumb_img_path,1))){
                                                    $thumb_img_path		= $thumb_img_path;									
                                                }else{
                                                    $thumb_img_path ='/images/not_found.gif'; 
                                                }
                                            }?>
                                             
                                            <li>								
                                                <div class="gi_div" style="width:108px; height:108px;">
                                                    <img src="<?=$thumb_img_path?>" style="vertical-align:middle;"/>
                                                </div>
                                                <div class="links">
                                                    <a href="/admin/hotel/gallery/<?=$hotel_image->hotel_id?>/3/<?=$hotel_image->id?>">Edit</a>
                                                    <a href="<?=$image_path?>" rel="facebox">View</a>
                                                    <a class="delete" href="#" onclick="javascript:delete_gi_confirmation('<?=$delete_path?>');">Delete</a>
                                                </div>
                                            </li><?
                                        }	
                                    }?>                    
                                </ul>
                                <?=$hotel_gallery_pagination?>
                                <div>
                                    <a href="/admin/hotel/gallery/<?=$hotel_id?>/2"><button id="btn_go_back" type="button" class="button">Add New Image</button></a>
                                </div>
                            </article>
                         </div>
                      </div>
					<div class="buttons">
                    	<button id="btn_go_back" type="button" class="button">Go Back</button>
						<button type="submit" class="button">Save Settings</button>
						<button id="btn_delete_hotel" type="button" class="button white">Delete Hotel</button>
					</div>
				<!--</form>-->
                <?=form_close()?>
			</article>
		</section>
	</section>
</section>

<footer id="bottom">
	<section class="container_12 clearfix">
		<div class="grid_6">
			<a href="#">Menu 1</a>
			&middot; <a href="#">Menu 2</a>
			&middot; <a href="#">Menu 3</a>
			&middot; <a href="#">Menu 4</a>
		</div>
		<div class="grid_6 alignright">
			Copyright &copy; 2011 <a href="#">YourCompany.com</a>
		</div>
	</section>
</footer>
 